# -*- coding: utf-8 -*-
# @Time : 2022/1/14 10:46
# @Author : Limusen
# @File : demo_connect_01


from appium import webdriver

des = {
    "platformName": "Android",
    "platformVersion": "9.0",
    "deviceName": "Samsung Galaxy S9",
    "appPackage": "com.android.calculator2",
    "appActivity": "com.android.calculator2.Calculator",
    "udid": "192.168.0.101:5555",
    "noReset": "True",
    "unicodeKeyboard": "True",
    "resetKeyboard": "True"
}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', des)

driver.find_element_by_xpath(
    '//android.widget.FrameLayout/android.widget.FrameLayout'
    '/android.widget.FrameLayout/android.view.ViewGroup'
    '/android.widget.LinearLayout/android.widget.LinearLayout[2]'
    '/android.view.ViewGroup[1]/android.widget.Button[2]').click()


# # 以什么元素开头    '//类名[contains(@元素名,"内容")]'  这里没有元素好定位的
# driver.find_element_by_xpath('//android.widget.Button[contains(@元素,"xxxxx")]').click()
# 元素包含某某内容   '//类名[contains(@元素名,"内容")]'
driver.find_element_by_xpath('//android.widget.Button[contains(@resource-id,"digit_6")]').click()
# 末尾开始匹配   '//类名[ends-with(@元素名,"内容")]'
driver.find_element_by_xpath('//android.widget.Button[ends-with(@resource-id,"eq")]').click()